package com.crape.common.constants;

import java.util.HashMap;
import java.util.Map;

public class ErrorCode {

    public static final String         key           = "errorCode";
    public static Map<Integer, String> codeMap       = new HashMap<Integer, String>();

    public static final Integer        SUCCES        = 0;
    public static final Integer        SUCCES_SAVE   = 1;
    public static final Integer        SUCCES_UPDATE = 2;

    static {
        ErrorCode.put(SUCCES, "处理成功！");
        ErrorCode.put(SUCCES_SAVE, "保存成功！");
        ErrorCode.put(SUCCES_UPDATE, "更新成功！");
    }

    private static void put(Integer code, String message) {
        if (code == null || message == null || codeMap.get(code) != null) {
            throw new IllegalArgumentException("ErrorCode pub error, this code is null or exsit! ");
        }
        codeMap.put(code, message);
    }

}
